<?php echo $header; ?><?php echo $column_left; ?><?php echo $column_right; ?>
<div id="content"><?php echo $content_top; ?>
  <div class="breadcrumb">
      <div class="line-hit"></div>
    <?php foreach ($breadcrumbs as $breadcrumb) { ?>
    <?php echo $breadcrumb['separator']; ?><a href="<?php echo $breadcrumb['href']; ?>"><?php echo $breadcrumb['text']; ?></a>
    <?php } ?>
  </div>
  <h1><?php echo $heading_title; ?></h1>
  <div class="product-info">
   <?php echo $description; ?>
  <div align="right" style="margin-bottom:10px; margin-right:15px;"><i><?php echo $text_date_added;?> <?php echo $date_added;?> <?php if ($author) { ?>
        <?php echo $text_author; ?> <a href="<?php echo $authors; ?>" style="text-decoration:none; font-weight:bold;"><?php echo $author; ?></a>
        <?php } ?></i> </div>
        
    <div class="right">
     
      
      <?php if ($comment_status) { ?>
      <div class="review">
        <div><img src="catalog/view/theme/default/image/stars-<?php echo $rating; ?>.png" alt="<?php echo $comments; ?>" />&nbsp;&nbsp;<a onclick="$('a[href=\'#tab-review\']').trigger('click');"><?php echo $comments; ?></a>&nbsp;&nbsp;|&nbsp;&nbsp;<a onclick="$('a[href=\'#tab-review\']').trigger('click');"><?php echo $text_write; ?></a>
        <div style="float:right"><!-- AddThis Button BEGIN -->
          <div class="addthis_default_style"><a class="addthis_button_compact"><?php echo $text_share; ?></a> <a class="addthis_button_email"></a><a class="addthis_button_print"></a> <a class="addthis_button_facebook"></a> <a class="addthis_button_twitter"></a></div>
          <script type="text/javascript" src="//s7.addthis.com/js/250/addthis_widget.js"></script> 
          <!-- AddThis Button END --> 
        </div></div>
      </div>
      <?php } ?>
    </div>
  </div>
  <div id="tabs" class="htabs">
    <?php if ($comment_status) { ?>
    <a href="#tab-review"><?php echo $tab_comment; ?></a>
    <?php } ?>
  
     <?php if ($thumb || $images) { ?>
    <a href="#tab-image"><?php echo $tab_image; ?></a>
    <?php } ?>
     <?php if ($downloads) { ?>
    <a href="#tab-download"><?php echo $tab_download; ?> (<?php echo count($downloads); ?>)</a>
    <?php } ?>
  </div>
  
  <?php if ($thumb || $images) { ?>
  <div id="tab-image" class="tab-content"> 
  
  <div class="product-info">
  
      
      <?php if ($thumb) { ?>
      <div style="text-align:center; margin-bottom:10px;"><a href="<?php echo $popup; ?>" title="<?php echo $heading_title; ?>" class="fancybox" rel="fancybox"><img src="<?php echo $thumb; ?>" title="<?php echo $heading_title; ?>" alt="<?php echo $heading_title; ?>" id="image"  style="border: 1px solid #e7e7e7; padding:3px;"/></a></div>
      <?php } ?>
      <?php if ($images) { ?>
      <div style="text-align:center;">
        <?php foreach ($images as $image) { ?>
        <span><a href="<?php echo $image['popup']; ?>" title="<?php echo $heading_title; ?>" class="fancybox" rel="fancybox" style="margin:3px;"><img src="<?php echo $image['thumb']; ?>" title="<?php echo $heading_title; ?>" alt="<?php echo $heading_title; ?>" style="border: 1px solid #e7e7e7; padding:3px;"/></a></span>
        <?php } ?>
      </div>
      <?php } ?>
      
      </div>
      
    </div>
    <?php } ?>
    
  <?php if ($downloads) { ?>
  <div id="tab-download" class="tab-content"> 
   <?php if ($this->config->get('config_login_to_download')==1) { ?>
    <div class="attention"><?php echo $text_login_to_download;?></div>
    <?php } ?>
  <div class="box-product" align="center">
 		<?php foreach ($downloads as $download) { ?>
      <div>
        <?php if ($download['thumb']) { ?>
       <div class="image"><a href="<?php echo $download['href']; ?>" title="<?php echo $download['mask']; ?>"><img src="<?php echo $download['thumb']; ?>" alt="<?php echo $download['mask']; ?>" /></a></div>
        <?php } ?>
        <div class="name"><a href="<?php echo $download['href']; ?>"><?php echo $download['name']; ?></a></div>
       </div>
      <?php } ?>
      
      </div>
      
    </div>
    <?php } ?>
    
 
  <?php if ($comment_status) { ?>
  <div id="tab-review" class="tab-content">
    <div id="review"></div>
    <h2 id="review-title"><?php echo $text_write; ?></h2>
    <b><?php echo $entry_name; ?></b><br />
    <input type="text" name="name" value="" />
    <br />
    <br />
    <b><?php echo $entry_comment; ?></b>
    <textarea name="text" cols="40" rows="8" style="width: 98%;"></textarea>
    <span style="font-size: 11px;"><?php echo $text_note; ?></span><br />
    <br />
    <b><?php echo $entry_rating; ?></b> <span><?php echo $entry_bad; ?></span>&nbsp;
    <input type="radio" name="rating" value="1" />
    &nbsp;
    <input type="radio" name="rating" value="2" />
    &nbsp;
    <input type="radio" name="rating" value="3" />
    &nbsp;
    <input type="radio" name="rating" value="4" />
    &nbsp;
    <input type="radio" name="rating" value="5" />
    &nbsp;<span><?php echo $entry_good; ?></span><br />
    <br />
    <b><?php echo $entry_captcha; ?></b><br />
    <input type="text" name="captcha" value="" />
    <br />
    <img src="index.php?route=news/article/captcha" alt="" id="captcha" /> <a onclick="return change_captcha('captcha');" title="Reload">Reload</a><br />
    <br />
    <div class="buttons">
      <div class="right"><a id="button-review" class="button"><span><?php echo $button_continue; ?></span></a></div>
    </div>
  </div>
  <?php } ?>
  <?php if ($products) { ?>
  <!-- relate product --> <div class="box">
  <div class="box-heading"><?php echo $text_related_product; ?> (<?php echo count($products); ?>)</div>
  <div class="box-content">
    <div class="box-product" align="center">
      <?php foreach ($products as $product) { ?>
      <div>
        <?php if ($product['thumb']) { ?>
       <div class="image"><?php if ($product['special']) { ?><div class="label"></div><?php }?><a href="<?php echo $product['href']; ?>"><img src="<?php echo $product['thumb']; ?>" alt="<?php echo $product['name']; ?>" /></a></div>
        <?php } ?>
        <div class="name"><a href="<?php echo $product['href']; ?>"><?php echo $product['name']; ?></a></div>
        <?php if ($product['price']) { ?>
        <div class="price">
          <?php if (!$product['special']) { ?>
          <?php echo $product['price']; ?>
          <?php } else { ?>
          <span class="price-old"><?php echo $product['price']; ?></span> <span class="price-new"><?php echo $product['special']; ?></span>
          <?php } ?>
        </div>
        <?php } ?>
        <?php if ($product['rating']) { ?>
        <div class="rating"><img src="catalog/view/theme/default/image/stars-<?php echo $product['rating']; ?>.png" alt="<?php echo $product['reviews']; ?>" /></div>
        <?php } ?>
        <a onclick="addToCart('<?php echo $product['product_id']; ?>');" class="button"><span><?php echo $button_cart; ?></span></a></div>
      <?php } ?>
    </div>  
  </div>
</div>
  <!-- //relate product --> 
 <?php } ?>
  <?php if ($articles) { ?>
  <!-- relate article --> 
  <div class="box">
  <div class="box-heading"><?php echo $tab_related; ?> (<?php echo count($articles); ?>)</div>
  <div class="box-content">
    <div class="product-list">
      <?php foreach ($articles as $article) { ?>
      <div>
        <?php if ($article['thumb']) { ?>
       <div class="image"><a href="<?php echo $article['href']; ?>"><img src="<?php echo $article['thumb']; ?>" alt="<?php echo $article['name']; ?>" /></a></div>
        <?php } ?>
        <div class="name"><a href="<?php echo $article['href']; ?>"><?php echo $article['name']; ?></a></div>
        
        <div class="description">
        <div style="font-size:11px;"><?php echo $text_date_added;?> <i><?php echo $article['date_added']; ?></i> 
        <?php echo $text_author;?> <a href="<?php echo $article['author_href']; ?>" style="font-size:11px;text-decoration: none"><?php echo $article['author']; ?></a> 
        <?php echo $article['comments']; ?> <?php echo $article['viewed']; ?> </div> 
        <?php echo $article['description']; ?><br> 
        <a style="float:right" href="<?php echo $article['href']; ?>" class="button"><span><?php echo $text_more; ?></span></a></div>       
        <?php if ($article['rating']) { ?>
        <div class="rating"><img src="catalog/view/theme/default/image/stars-<?php echo $article['rating']; ?>.png" alt="<?php echo $article['comments']; ?>" /></div>
        <?php } ?></div>
      <?php } ?>
    </div>  
  </div>
</div>
  <!-- //relate article --> 
  <?php } ?>
  
  <?php if ($tags) { ?>
  <div class="tags"><b><?php echo $text_tags; ?></b>
    <?php for ($i = 0; $i < count($tags); $i++) { ?>
    <?php if ($i < (count($tags) - 1)) { ?>
    <a href="<?php echo $tags[$i]['href']; ?>"><?php echo $tags[$i]['tag']; ?></a>,
    <?php } else { ?>
    <a href="<?php echo $tags[$i]['href']; ?>"><?php echo $tags[$i]['tag']; ?></a>
    <?php } ?>
    <?php } ?>
  </div>
  <?php } ?>
  <?php echo $content_bottom; ?></div>
  <script type="text/javascript"><!--
$('.fancybox').fancybox({cyclic: true});
//--></script> 
<script type="text/javascript"><!--
$('#review .pagination a').live('click', function() {
	$('#review').fadeOut('slow');
		
	$('#review').load(this.href);
	
	$('#review').fadeIn('slow');
	
	return false;
});			

$('#review').load('index.php?route=news/article/comment&article_id=<?php echo $article_id; ?>');

$('#button-review').bind('click', function() {

	function clear_data(){ 
		$('input[name=\'name\']').val('');
			$('textarea[name=\'text\']').val('');
			$('input[name=\'rating\']:checked').attr('checked','');
			$('input[name=\'captcha\']').val('');
	}
	function change_captcha(){
		var obj=document.getElementById("captcha");
		var src=obj.src;
		var date=new Date();
		obj.src=src + '&' + date.getTime();
	}
	function show_review(){ 
		$.get("index.php?route=news/article/comment&article_id=<?php echo $article_id;?>",function(data){ 
		$("#review").html(data);
		});	
	}
	$.ajax({
		url: 'index.php?route=news/article/write&article_id=<?php echo $article_id; ?>',
		type: 'post',
		dataType: 'json',
		data: 'name=' + encodeURIComponent($('input[name=\'name\']').val()) + '&text=' + encodeURIComponent($('textarea[name=\'text\']').val()) + '&rating=' + encodeURIComponent($('input[name=\'rating\']:checked').val() ? $('input[name=\'rating\']:checked').val() : '') + '&captcha=' + encodeURIComponent($('input[name=\'captcha\']').val()),
		beforeSend: function() {
			$('.success, .warning').remove();
			$('#button-review').attr('disabled', true);
			$('#review-title').after('<div class="attention"><img src="catalog/view/theme/default/image/loading.gif" alt="" /> <?php echo $text_wait; ?></div>');
		},
		complete: function() {
			$('#button-review').attr('disabled', false);
			$('.attention').remove();
		},
		success: function(data) {
			if (data['error']) {
				$('#review-title').after('<div class="warning">' + data['error'] + '</div>');
			}
			
			if (data['success']) {
				$('#review-title').after('<div class="success">' + data['success'] + '</div>');
				clear_data();
				change_captcha();
				show_review();
			}
		}
	});
});
//--></script> 
<script type="text/javascript"><!--
$('#tabs a').tabs();
//--></script> 
<script type="text/javascript"><!--
function change_captcha(id){
var obj=document.getElementById(id);
var src=obj.src;var date=new Date();
obj.src=src + '&' + date.getTime();
			return false;}
//--></script> 
<?php echo $footer; ?>